﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBUtility;

public partial class Manageweb_ManageINews_INewsRecycle : System.Web.UI.Page
{
    MODEL.INews MIN = new MODEL.INews();
    MODEL.INews _MIN = new MODEL.INews();

    BLL.INews BIN = new BLL.INews();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["MasterID"] == null)
        {
            Response.Redirect("../Default.aspx");
        }
    }


    #region 图文图片 [格式化]
    protected string FormatThumb(object _Thumb)
    {
        if (_Thumb.ToString() == "")
        {
            return "~/Manageweb/images/null.jpg";
        }
        else
        {
            return "~/UploadImage/" + _Thumb.ToString();
        }
    }
    #endregion


    #region 修改按钮 [GridView] [Command]
    protected void LBtn_Mod_Command(object sender, CommandEventArgs e)
    {
        try
        {
            Response.Redirect("AddINews.aspx?INewsID=" + e.CommandArgument);
        }
        catch (Exception ex)
        {
            LB_INewsRecycle.Text = ex.Message;
        }
    }
    #endregion


    #region 恢复按钮 [GridView] [Command]
    protected void LBtn_RollBack_Command(object sender, CommandEventArgs e)
    {
        try
        {
            MIN.IN_ID = Convert.ToInt32(e.CommandArgument);

            BIN.MarkIsDel(MIN);

            LB_INewsRecycle.Text = "恢复成功";

            GV_DelINewsList.DataBind();
        }
        catch (Exception ex)
        {
            LB_INewsRecycle.Text = ex.Message;
        }
    }
    #endregion


    #region 确认删除按钮 [GridView] [Command]
    protected void LBtn_RealDel_Command(object sender, CommandEventArgs e)
    {
        try
        {
            MIN.IN_ID = Convert.ToInt32(e.CommandArgument);

            BIN.Del(MIN);

            LB_INewsRecycle.Text = "删除成功";

            GV_DelINewsList.DataBind();
        }
        catch (Exception ex)
        {
            LB_INewsRecycle.Text = ex.Message;
        }
    }
    #endregion


    #region 搜索按钮 [Click]
    protected void Btn_Search_Click(object sender, EventArgs e)
    {
        try
        {
            string SQLstr_Search = "SELECT * FROM ([INews] INNER JOIN [INewsClass] ON ";

            SQLstr_Search += " INews.IN_ClassID = INewsClass.INC_ID) WHERE [IN_IsDel]=true ";

            SQLstr_Search += " AND [IN_Title] LIKE '%" + TB_Search.Text + "%' ";

            SQLstr_Search += " ORDER BY [IN_DateTime] DESC";

            DataTable DT_Search = AccHelper.GetDataTable(SQLstr_Search);

            GV_DelINewsList.DataSourceID = "";

            GV_DelINewsList.DataSource = DT_Search.DefaultView;

            GV_DelINewsList.DataBind();
        }
        catch (Exception ex)
        {
            LB_INewsRecycle.Text = ex.Message;
        }
    }
    #endregion
}
